<?php
$uid = Yii::app()->user->id;
if(Yii::app()->user->getState($uid) != NULL)
{
    $storedList = Yii::app()->user->getState($uid);
    $quantitylist = Yii::app()->user->getState('quantity');
    if(array_search($id, $storedList) === false)
    {
        $storedList[] = $id;
        $newquantitylist = array($id => $quantity);
        $result = $quantitylist + $newquantitylist;
        Yii::app()->user->setState($uid, $storedList);
        Yii::app()->user->setState('quantity', $result);
    }
}
else
{
    $storedList = array($id);
    $quantitylist[$id] = $quantity;
    Yii::app()->user->setState($uid, $storedList);
    Yii::app()->user->setState('quantity', $quantitylist);
}
    
    $this->renderPartial('DisplayCart');

?>
